'use strict';
// Copyright 2014 Blueant Inc. All Rights Reserved.

/**
 * @fileoverview 受到其他玩家攻击时胜利N次
 * @author sundbcn@gmail.com (sun debing)
 */

var _ = require('lodash');

var CopyCondition = function () {

};

/**
 * 验证
 */
CopyCondition.prototype.getProgress = function (condition, record, damage_build_list, data) {
    var destroy_per = 0;
    var def_build_list = record.getDefBuildList();
    _.each(damage_build_list, function (damage_build) {
        // 计算占比
        _.some(def_build_list, function (def_build) {
            if (def_build.build_id == damage_build.build_id) {
                destroy_per += def_build.per / 100;
                return true;
            }
        });
    });

    var is_pass = false;
    if (destroy_per >= 0.95) {
        is_pass = true;
    }

    return {
        progress: 0,
        total_progress: 0,
        is_pass: Number(is_pass)
    };
};

module.exports = new CopyCondition();
